package com.wenyl.juc.thread.saleTickets;

import lombok.Data;

/**
 * @author Swimming Dragon
 * @description: TODO
 * @date 2024年11月07日 11:40
 */
@Data
public class Tickets {
    private int allowance;
    public Tickets(int allowance){
        this.allowance = allowance;
    }
    // 购票
    public synchronized void buyTicket(int num){
        int before = this.allowance;
        int after = before-num;
        this.setAllowance(after);
    }
}
